<?php
namespace app\index\controller;

use think\Cache;
use think\Db;
use think\Controller;
use think\Config;
use think\Log;
use think\Session;



class Pay extends Controller
{

    function __construct() {
        parent::__construct();
    }

    public function mzf_pay(){
        $money = $this->request->post('money');
        $return_url = $this->request->post('source');
        if(empty($money))return json(['status'=>9999,'data'=>'','msg'=>'金额不正确']);
        $user_info = Session::get('user_info');
        if(!empty($user_info))if(empty($money)) return json(['status'=>9999,'data'=>'','msg'=>'页面出错,请刷新页面']);
        $data['openid'] = $user_info->openid;
        $data['order_num'] = get_order_num();
        $data['price'] = $money+1;
//        $data['money'] = $money;
        $data['type'] = 3;
        $data['creat_time'] = time();
        $status = Db::table('codepay_order')->insertGetId($data);
        if(!$status) return json(['status'=>9999,'data'=>'','msg'=>'订单创建失败']);
        $pay_url = 'http://codepay.fateqq.com:52888/creat_order?id=14261&token=iWO60oJvAMeQ4h6yEh3GH36vOzmG0jFN&&price='.$money.'&pay_id='.$data['order_num'].'&type=3&page=4&outTime=360000&param='.$data['order_num'].'&return_url='.$return_url;
        $result = json_decode(http_curl($pay_url));
        return json($result);
    }

    //码支付回调接口
    public function mzf_notify(){
        Log::record($_REQUEST);
        $money = $this->request->post('money');//实际付款金额
        $pay_time = $this->request->post('pay_time');//付款的时间戳
        $pay_no = $this->request->post('pay_no');//付款的时间戳


    }
}


